Skip to content

Feature: Implement hot reload for engine.importJs #42

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Haltarys
Copy link

@Haltarys Haltarys commented Jul 5, 2025

I am using this plugin to add some interactivity to my notes. The JS code I write is kind of big, so, to avoid cluttering my note, I write the business logic in a separate JS file that I import using engine.importJs().

However, Obsidian caches the imports made by engine.importJs. Therefore, when re-running the code block, the engine.importJs('path/to/my/script.js') does not actually reload my script.js after I made changes to it. This considerably slows down my development as I have to continually reload Obsidian for the changes to take effect.

This PR implements a hot reload feature to actually load the script every time the code blocks is re-run.

💡 Hot reload is disabled by default, for backwards compatibility and to save memory.

⚠️ It may cause memory shortage if abused (and other bugs with instanceof, I read your comments), but it will considerably improve DX.

(Thank you for your hard work, Moritz Jung!)

Haltarys added 2 commits July 5, 2025 22:13
(Hot reload is disabled by default. It may cause memory shortage if abused, but it will considerably improve DX.)
@Haltarys Haltarys changed the title Implement hot reload for engine.importJs Feature: Implement hot reload for engine.importJs Jul 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant